<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
 <meta charset="utf-8">
 <title>督办过程监控</title>
 <meta name="renderer" content="webkit">
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 <link rel="stylesheet" href="../layui/css/layui.css" th:href="@{../layui/css/layui.css}" media="all">
<link href="favicon.ico" rel="shortcut icon">
</head>
<script th:src="@{../layui/layui.js}" charset="utf-8"></script>

<body>

<table class="layui-hide" id="demo" lay-filter="test"></table>



<script>
layui.use(['table','layedit','form','laydate'], function(){
	  var table = layui.table
	  var layedit = layui.layedit
	  ,$ = layui.jquery;
	  var form = layui.form   //form表单
	  var index = layedit.build("textarea", "content");
	  var laydate = layui.laydate //日期 
	  
//执行一个 table 实例
	table.render({
	  elem: '#demo'
	  ,height: 'full-210'
	  //,cellMinWidth: 50
	  ,url: 'showSuperVisionDraft' //数据接口
		  ,response: {
				statusCode: 200 //规定成功的状态码，默认：0
				} 
	  ,page: true
	  ,even:true	
	  //,page: true
	  //,title: '新闻表'
	  ,limit:20
	  ,toolbar:'#toolbarDemo'  //开启工具栏
	  ,cols: [
		  [ //表头
		{ type: 'numbers', title: '序号' }
	    /* ,{field: 'svid', title: '序号', sort: true, fixed: 'left', width:50} */
	    ,{field: 'svTitle', title: '督办标题'}
	    ,{field: 'svContent', title: '督办内容', width:200}
	    ,{field: 'sname', title: '督办类型', width:120}
	    /* ,{field: 'sid', title: '督办类型', width:120}
	    ,{field: 'did', title: '督办类型', width:120} */
	    ,{field: 'dname', title: '督办部门', width:130}
	    ,{field: 'startTime', title: '发起督办时间'}
	    ,{field: 'confirmTime', title: '签收时间'}
	    ,{field: 'endTime', title: '截止时间'}
	    ,{field: 'stid', title: '督办状态',width:100}
	    ,{field: 'sendLeader', title: '通知分管领导'}
	    ,{field: 'replices', title: '回复次数',width:100}
	    /* ,{field: 'pressMsg', title: '催促确认提示消息',width:100} */
	    ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:260}
	 	 ]
		]
	});

	});
</script>


 <!------------------------------------------------ 修改 ----------------------------------------------------->
<form class="layui-form layui-form-pane1" lay-filter="updateData" id="update" action="/superVision/updateSuperVision" method="post"  hidden="true">	
 	<input type="hidden" name="svid">
  <div class="layui-form-item">
    <label class="layui-form-label">督办标题</label>
    <div class="layui-input-block">
      <input type="text" name="svTitle" lay-verify="title" autocomplete="off" placeholder="请输入督办标题" class="layui-input">
  </div>
  </div>
   <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">督办内容</label>
    <div class="layui-input-block">
      <textarea placeholder="请输入内容" class="layui-textarea" name="svContent"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">选择发送部门</label>
    <div class="layui-input-block">
        <select name="did" id="bumen" lay-filter="bumen"> 
        <option th:each="dept,userStat:${depts}" th:value="${dept?.did}" th:text="${dept?.dname}"></option>
      </select> 
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">督查类型</label>
    <div class="layui-input-block">
       <select name="sid" id="sid" lay-filter="dept"> 
        <option th:each="superVisionType,userStat:${superVisionTypes}" th:value="${superVisionType.sid}" th:text="${superVisionType.sname}"></option>
      </select> 
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">签收时间</label>
  <div class="layui-inline">
	  <input type="text" name="confirmTime" class="layui-input" id="test6-3">
  </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">结束时间</label>
	  <div class="layui-inline">
		  <input type="text" name="endTime" class="layui-input" id="test6-2">
	  </div>
  </div>
    <div class="layui-form-item">
    <label class="layui-form-label">通知分管领导</label>
    <div class="layui-input-block">
      <input type="radio" name="sendLeader" value="通知" title="通知">
      <input type="radio" name="sendLeader" value="不通知" title="不通知" checked>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">设置回复次数</label>
    <div class="layui-input-block">
      <select name="replices" >
      	<option value="1">请选择</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
      </select>
    </div>
  </div>
  <input type="hidden" name="state">
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="first">保存修改信息</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>


<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="update">修改</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  <a class="layui-btn layui-btn-xs" lay-event="start">发起督办</a>
</script>

<script type="text/javascript" th:inline="javascript">  //用javascript获取model中数据
layui.use(['table', 'form', 'layedit', 'laydate'], function(){
	  var form = layui.form   //form表单
	  var layer = layui.layer  //弹出层
	  var $=layui.$;
  	  var table = layui.table;
  //监听工具条
  table.on('tool(test)', function(obj){
    var data = obj.data;
    var svid = data.svid;
    if(obj.event === 'update'){
    	//layer.alert(JSON.stringify(data));
    	//1.获取这行数据
    	//2.填充form
    	form.val("updateData",data); 
    	//首先需要使用lay-value来确定需要设置哪个元素自动选择
    	
    	//将部门选中状态改为之前的
    	layer.open({
    		type:1,
			title:'修改督办信息',
			area:'800px',
			anim: 1,
			skin: 'layui-layer-lan',
			content:layui.$('#update'),	
    	}) 
    }else if(obj.event === 'start'){
    	  layer.confirm('确认要发起督办吗,是否继续?', function(index){
        	  layui.$.ajax({
                  url: "superVisionStart",
                  type: "POST",
                  data:{"svid":data.svid,"sid":data.sid,"did":data.did},
                  dataType: "json",                
                  success: function(data){            
                  if(data==null){    
                     layer.msg("发起失败");                        
                  }else{ 
                      layer.msg("发起成功");   
                      obj.del();
                      }
                  },
                  error:function(){
                	  layer.closeAll();
                      parent.location.reload();
                      Load(); 
                      //tableObj.reload(options); //重载表格
                  },
        	  });
          });
    } else if(obj.event === 'del'){
      layer.confirm('删除后不可恢复,是否继续?', function(index){
    	  layui.$.ajax({
              url: "superVisionDelete",
              type: "POST",
              data:{"svid":data.svid},
              dataType: "json",                
              success: function(data){  
            	  //layer.alert(JSON.stringify(data));
              if(data!=null){    
                 layer.msg("删除成功"); 
                 obj.del();
              }else{ 
                  layer.msg("删除失败");   
                  }
              },
              error:function(){
            	  layer.closeAll();
                  parent.location.reload();
                  Load(); //删除完需要加载数据
                  //
              },
    	  });
      });
    };
  });
});
/*部门两级联动代码开始 
layui.use(['form'], function(data){
	  var form = layui.form;
	  var $=layui.$;
	  form.on('select(bumen)', function(data){	 
	  $.getJSON("/superVision/toGetDepts?parentId="+data.value, function(data){
	        var optionstring = "";
	        $.each(data.list, function(i,item){
	            optionstring += "<option value=\"" + item.did + "\" >" + item.dname + "</option>";
	        }); 
	        layui.$("#did").html('<option value=""></option>' + optionstring);
	        form.render('select'); //这个很重要
	    });
	  });
	});
结束 */
/*发起督查时间选择代码开始  */
  layui.use('laydate', function(){
	  var laydate = layui.laydate;  
	  //自定义背景色主题
	  laydate.render({
	    elem: '#test6-2' //指定元素
	    ,type: 'datetime'
	    ,theme: '#393D49'
	    //,range: true
	    ,trigger: 'click'
	  });
	  //自定义背景色主题
	  laydate.render({
	    elem: '#test6-3' //指定元素
	    ,type: 'datetime'
	    ,theme: '#393D49'
	    //,range: true
	    ,trigger: 'click'
	  });
	  //自定义背景色主题
	  laydate.render({
	    elem: '#test6-1' //指定元素
	    ,type: 'datetime'
	    ,theme: '#393D49'
	    //,range: true
	    ,trigger: 'click'
	  });
	});
 /*结束*/
</script>
</body>
</html>